<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;

use App\Models\Serve;
use App\Models\Leimu;

use DB;

class ServeController extends Controller
{
    //全部服务
    public function alllist(){

		//取出已有服务列表
    	$serve = Serve::get();
    	//取出所有类目
    	$leimu = DB::table('class')->select('id','classname')->get();
    	//取出第一个leimu 
    	$d_class = DB::table('class')->OrderBy('id','desc')->select('id','classname')->first();

    	$leimums = Leimu::get();

    	//声明一个空数组
    	$class = array();

    	//所有类目
    	foreach($leimu as $lv){

    		$class[] = $lv;
    	}

    	//取出第一项类目信息
    	$d_serve = Leimu::LeftJoin('serves','leimus.serve_a','=','serves.id')
    						->where('leimus.cid',$d_class->id)
    						->select('serves.title','serves.commit','serves.path')
    						->get();
    						

    	return ['status'=>'ok','class' =>$class,'d_class'=>$d_serve];
    }

    //服务分类
    public function class(){

    	return 123;
    }
}
